import utils from './utils'

function loginOk(username) {
	window.sessionStorage.setItem('username',username);
}

function isLogin() {
	const username = window.sessionStorage.getItem('username');
	return !utils.isNullOrUndefined(username);
}

function logout(router) {
    window.sessionStorage.clear();
    if( router.currentRoute.path !=='/login'){
        router.replace("/");
    }
}

export default {
	isLogin,
	logout,
	loginOk
};